css:
  /*隐藏时间*/
  .fc-content .fc-time{
    display: none !important;
  }
.panel.panel-default
  .panel-heading
    .panel-title
      .html_title= @html_title || params[:action]
      .pull-right
        | 显示模式：
        = select_tag 'view_type', options_for_select([['所有任务','1'],['待完成任务','2']], params[:view_type]),
                class: 'form-control normal-input'
  .panel-body
    .js-calendar
javascript:
  $('#view_type').change(function(){
    Turbolinks.visit("#{request.url.split('?').first}?view_type="+$(this).val())
  })

  var $date = new Date();
  var $d = $date.getDate();
  var $m = $date.getMonth();
  var $y = $date.getFullYear();

  jQuery('.js-calendar').fullCalendar({
    locale: 'zh-cn',
    firstDay: 1,
    editable: true,
    droppable: true,
    timezone: 'local',
    defaultView: 'agendaWeek',
    contentHeight: 'auto',
    allDaySlot: false,
    header: {
      center: 'title',
      left: '',
      right: 'prev,today,next month,agendaWeek,agendaDay'
    },
    businessHours: {
      dow: [1, 2, 3, 4, 5],
      start: '09:00',
      end: '18:00'
    },
    selectable: true,
    minTime: '09:00',
    maxTime: '18:00',
    select: function (start, end, jsEvent, view) {
      //$('#show_calendar_dialog_div').load('/fg/task_calendars/new?start=' + start.format() + '&end=' + end.format() + '&user_id=' + $('.selected_user').data('user-id')).dialog({
      //  title: '添加计划安排',
      //  width: 600,
      //  height: 345
      //})
    },
    eventClick: function (event, jsEvent, view) {
      console.log(jsEvent.target)
      console.log(event)
      $('#application-modal').modal({remote: '/sales/follow_ups/'+event.id, show: true});
      //if (jsEvent.target.tagName == 'DIV') {
      //  if (event.task_id != null) {
      //    url = "/fg/tasks/" + event.task_id + "?use_dialog=true"
      //    $("#show_fg_task_dialog_div").html('加载中...').load(url).dialog({title: '工单详情', width: 1200, height: 650})
      //    return false
      //  } else {
      //    url = "/fg/task_calendars/" + event.id + "/edit"
      //    $('#show_calendar_dialog_div').load(url).dialog({title: '修改计划安排', width: 600, height: 345})
      //  }
      //
      //}
    },
    eventResize: function (event, delta, revertFunc) {
      //console.log(event)
      //console.log(delta)
      show_notice('不能调整时间范围！')
      revertFunc.call()
      //update_appoint(event, revertFunc)
    },
    eventRender: function (event, element, view) {

    },
    // 拖动事件到指定位置
    eventDrop: function (event, delta, revertFunc, jsEvent, ui, view) {
      if (event.allDay && view.name == "agendaWeek") {
        alert('不允许安排全天！')
        revertFunc.call()
      } else {
        console.log('change',event)
        $.ajax({
          url: "/sales/follow_ups/"+event.id,
          type: 'put',
          data:
            {'sales_follow_up': {'appointment_time': event.start.toString()}}
          ,
          dataType: 'json',
          success: function(res){
            console.log(res)
            show_notice('安排成功！')
          },
          error: function(){
            error_notice('操作失败！')
            revertFunc.call()
          }

        })

      }
    },

    eventDragStart: function (event, jsEvent, ui, view) {
      //console.log('start drag',event)
    },
    drop: function ($date, $allDay) { // this function is called when something is dropped
      // retrieve the dropped element's stored Event Object
      var $originalEventObject = jQuery(this).data('eventObject');

      // we need to copy it, so that multiple events don't have a reference to the same object
      var $copiedEventObject = jQuery.extend({}, $originalEventObject);

      // assign it the date that was reported
      $copiedEventObject.start = $date;

      // render the event on the calendar
      // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
      jQuery('.js-calendar').fullCalendar('renderEvent', $copiedEventObject, true);

      // remove the element from the "Draggable Events" list
      jQuery(this).remove();
    },
    events: #{@follow_ups.to_json.html_safe}
  });

  //
  //$("#calendar").fullCalendar({
  //  events: {
  //    events,
  //    textColor: '#6C6C6C'
  //  },
  //  locale: 'zh-cn',
  //  timezone: 'local',
  //  height: 'auto',
  //  customButtons: {
  //    refresh_current: {
  //      text: '刷新',
  //      click: function () {
  //        refresh_user_data()
  //      }
  //
  //    }
  //  },
  //  header: {
  //    left: 'prev,next today',
  //    center: 'title refresh_current',
  //    right: 'agendaWeek,month,listWeek'
  //  },
  //
  //  contentHeight: 'auto',
  //  allDaySlot: false,
  //  defaultView: 'agendaWeek',
  //  weekends: calendar_weekends,
  //  dayClick: function (e) {
  //    // console.log('day click',e)
  //  },
  //  eventClick: function (event, jsEvent, view) {
  //    console.log(jsEvent.target)
  //    console.log(event.task_id)
  //    if (jsEvent.target.tagName == 'DIV') {
  //      if (event.task_id != null) {
  //        url = "/fg/tasks/" + event.task_id + "?use_dialog=true"
  //        $("#show_fg_task_dialog_div").html('加载中...').load(url).dialog({title: '工单详情', width: 1200, height: 650})
  //        return false
  //      } else {
  //        url = "/fg/task_calendars/" + event.id + "/edit"
  //        $('#show_calendar_dialog_div').load(url).dialog({title: '修改计划安排', width: 600, height: 345})
  //      }
  //
  //    }
  //  },
  //  eventResize: function (event, delta, revertFunc) {
  //    update_appoint(event, revertFunc)
  //  },
  //  // eventTextColor:{
  //  //  "blue"
  //  // }
  //
  //  eventRender: function (event, element, view) {
  //    if (view.name == "listWeek") {
  //      element.find('.fc-list-item-title').html(element.find('.fc-list-item-title').text().replace(/<\/?.*?>/, ""))
  //    } else {
  //      element.find('.fc-title').html(element.find('.fc-title').text())
  //    }
  //    // element.append( "<span class='closeon'>X</span>" );
  //    // element.find(".closeon").click(function() {
  //    //    $('#calendar').fullCalendar('removeEvents',event._id);
  //    // });
  //    // event.textColor = 'red'
  //  },
  //  businessHours: {
  //    dow: [1, 2, 3, 4, 5],
  //    start: start_time,
  //    end: end_time
  //  },
  //  selectable: true,
  //  minTime: start_time,
  //  maxTime: end_time,
  //  select: function (start, end, jsEvent, view) {
  //    $('#show_calendar_dialog_div').load('/fg/task_calendars/new?start=' + start.format() + '&end=' + end.format() + '&user_id=' + $('.selected_user').data('user-id')).dialog({
  //      title: '添加计划安排',
  //      width: 600,
  //      height: 345
  //    })
  //  },
  //  eventDragStart: function (event, jsEvent, ui, view) {
  //    //console.log('start drag',event)
  //  },
  //  eventDragStop: function (event, jsEvent, ui, view) {
  //    // console.log(jsEvent.target.id)
  //    // console.log(jsEvent.target.tagName)
  //    if (jsEvent.target.id == 'task_list'
  //        || jsEvent.target.tagName == 'H5'
  //        || jsEvent.target.tagName == 'LABEL'
  //        || jsEvent.target.className.indexOf('tasks') == 0
  //        || jsEvent.target.className.indexOf('for_search') == 0
  //        || jsEvent.target.id == 'tasks_in_calendar') {
  //      if (confirm('确定要删除安排?')) {
  //        destroy_appoint(event)
  //      }
  //
  //    }
  //  },
  //  eventDrop: function (event, delta, revertFunc, jsEvent, ui, view) {
  //    // if(event.start.weekday()==6 && event.allDay ){
  //    //   if(confirm('确定删除安排？')){
  //    //     destroy_appoint(event, revertFunc)
  //    //   }else {
  //    //     //destroy_appoint(event, revertFunc)
  //    //     revertFunc.call()
  //    //   }
  //    // }else
  //    if (event.allDay && view.name == "agendaWeek") {
  //      alert('不允许安排全天！')
  //      revertFunc.call()
  //    } else {
  //      // 拖动事件到指定位置
  //      update_appoint(event, revertFunc)
  //    }
  //  },
  //  // 日历收到从列表挪过来的task
  //  eventReceive: function (event) {
  //    // console.log('receive',event)
  //    // $('#calendar').fullCalendar('updateEvent', event);
  //  },
  //  // eventRender: function(event, element) {
  //  //   console.log('render event', event, element)
  //  // },
  //  droppable: true,
  //  // 待安排列表的移出
  //  drop: function (date, jsEvent, ui, resourceId) {
  //    console.log(jsEvent.target.className)
  //    if (jsEvent.target.className == 'fc-highlight' || jsEvent.target.className.indexOf('fc-day-top') == 0) {
  //      create_appoint(this, date)
  //    }
  //
  //  },
  //  // eventDestroy: function( event, element, view ) {
  //  //   console.log('event destroy', event)
  //  // }
  //
  //})